import styled from "styled-components";

export const Input = ({ label, ...props }: any) => {
  return (
    <InputWrap>
      <Span>{label}</Span>
      <InputStyled {...props}></InputStyled>
    </InputWrap>
  );
};

const Span = styled.span`
  font-size: 0.5rem;
  position: absolute;
  color: #999;
  padding: 0 3px;
  top: 0;
  left: 1rem;
  background-color: #fff;
`;

const InputWrap = styled.div`
  position: relative;
  height: 4rem;
  width: 15rem;
  display: inline-flex;
  align-items: center;
  /* 移动端 hover 可以达到 点击 input时触发 */
  &:hover ${Span} {
    color: #51f;
  }
`;

const InputStyled = styled.input`
  width: 15rem;
  height: 2rem;
  padding: 0.2rem;
  &:focus {
    outline-color: #51f;
  }
`;
